﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ggdll.GGMessages.Incoming
{
    public class GGIncomingMessage
    {
        public int sender;
        public int seq;
        public int time;
        public int messageclass;
        public int offset_plain;
        public int offset_attributes;
        public string html;
        public string plain_message;
        public string attributes;

        public GGIncomingMessage(byte[] data)
        {
            int message_size=BitConverter.ToInt32(data, 4);
            sender = BitConverter.ToInt32(data, 8);
            seq = BitConverter.ToInt32(data, 12);
            time = BitConverter.ToInt32(data, 16);
            messageclass = BitConverter.ToInt32(data, 20);
            offset_plain = BitConverter.ToInt32(data, 24);
            offset_attributes = BitConverter.ToInt32(data, 28);
            html = new string(StaticVars.enc.GetChars(data, 32, offset_plain-24-1));
            plain_message = new string(StaticVars.ASCIIenc.GetChars(data, offset_plain+8, offset_attributes - offset_plain-1));
            return;
        }
    }
}
